package vip.meeet.algorithm.arr;


import java.util.Arrays;

public class Num26 {

    public static void main(String[] args) {
        int[] a = {1,1,2};
//        int[] a = {1,1};
        removeDuplicates(a);
        System.out.println(Arrays.toString(a));

    }
    public static int removeDuplicates(int[] nums) {
        if(nums.length <= 0){
            return nums.length;
        }
        int pre = nums[0];
        int len = 1;
        for(int i=1;i<nums.length;i++){
            while (i<nums.length && nums[i] == pre){
                i++;
            }
            if(i == nums.length){
                break;
            }
            if(nums[i] != pre){
                pre = nums[i];
                nums[len++] = pre;
            }
        }
        return len;
    }
}
